var now = new Date();  
          
        var year = now.getFullYear();       //年  
        var month = now.getMonth() + 1;     //月  
        var day = now.getDate();            //日  
        if (month < 10) {
		    month = "0" + month;
		}
		if (day < 10) {
		    day = "0" + day;
		}
   		var mytime = year.toString() + month.toString() + day.toString();
   		// console.log(mytime);


//获取报警图片
exports.getFalseImage = function(req,res){
	// console.log("111");
	req.getConnection(function(err,conn){
		if(err){
			console.log("Failed to connection");
			res.status(500).json(err);
		};
		var query = conn.query("SELECT * FROM `" + mytime +"` WHERE msinfo=1",function(srr,rows){
			if(err){
				console.log(err);
			}
			else{
				res.status(200).json({"image":rows});
			}
		});
	})
};

//根据日期选择误报图片
exports.searchFalseImage = function(req,res){
	// var aaaa = req.body;
	console.log(req.query.date);
	console.log(req.query.timeStart);
	console.log(req.query.timeEnd);
	req.getConnection(function(err,conn){
		if(err){
			console.log("Failed to connect");
			res.status(500).json(err);
		};

		var queryString = '';
		queryString += 'SELECT * FROM' + '\`' + req.query.date + '\`' + 'where time >= ' + '\'' + req.query.timeStart + '\'' + 'and time <= ' + '\''+ req.query.timeEnd + '\'' + 'and msinfo = 1' + ';';
		var query = conn.query(queryString,function(err,rows){
			// console.log("aaaa");
			if(err){
				console.log(err);
			}
			else{
				res.status(200).json({"image":rows});
			}
		});
	})
};